package com.freecloud.framework.constant;

import lombok.Getter;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * 常量
 * 
 * @author maomao
 * @email 138383877@qq.com
 */
public class Constant {

    /**
     * webRoot根路径地址，项目启动自动设置
     */
    public static String ROOTPATH = System.getProperty("webPath");

	/** 超级管理员ID */
	public static final int SUPER_ADMIN = 1;

    /**
     * 用户token参数名
     */
	public static final String TOKEN_NAME = "token";

    /**
     * 用户cookie中的token参数名
     */
	public static final String TOKEN_COOKIE_NAME = "free-token";

    /**
     * client TOKEN 私钥
     */
	public static final String CLIENT_TOKEN_PASSWORD_KEY = "free-cloud";

    /**
     * client Token 私钥分割字符串
     */
	public static final String CLIENT_TOKEN_PASSWORD_PARTITION = ";";

	/**
	 * 菜单类型
	 * 
	 * @author maomao
	 * @email 138383877@qq.com
	 */
    public enum MenuType {
        /**
         * 目录
         */
    	CATALOG(0),
        /**
         * 菜单
         */
        MENU(1),
        /**
         * 按钮
         */
        BUTTON(2);

        private int value;

        private MenuType(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }
    }
    
    /**
     * 定时任务状态
     * 
     * @author maomao
     * @email 138383877@qq.com
     */
    public enum ScheduleStatus {
        /**
         * 正常
         */
    	NORMAL(0),
        /**
         * 暂停
         */
    	PAUSE(1);

        private int value;

        private ScheduleStatus(int value) {
            this.value = value;
        }
        
        public int getValue() {
            return value;
        }
    }

    /**
     * 云服务商
     */
    public enum CloudService {
        /**
         * 七牛云
         */
        QINIU(1),
        /**
         * 阿里云
         */
        ALIYUN(2),
        /**
         * 腾讯云
         */
        QCLOUD(3);

        private int value;

        private CloudService(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }
    }

    /**
     * 删除标识
     */
    public enum DeleteFlag{
        /**
         * 已删除
         */
        DELETE("0","删除"),
        /**
         * 正常
         */
        NORMAL("1","正常"),
        /**
         * 审核中
         */
        AUDIT("2","审核中");

        private String code;
        private String name;

        DeleteFlag(String code,String name){
            this.code = code;
            this.name = name;
        }

        public String getCode(){
            return this.code;
        }
    }

    /**
     * 默认版本号
     */
    public static String CLOUD_APP_VERSION = "1.0.0";
    /**
     * 默认地址
     */
    public static String CLOUD_APP_URL = "http://www.free-js.com";

    /**
     * 应用模块基本信息
     */
    @Getter
    public enum CloudApp{

        OSS("oss","free-cloud-oss","free-cloud-oss对象存储",CLOUD_APP_VERSION,CLOUD_APP_URL),
        SYSTEM("system","free-cloud-system","free-cloud-system系统信息，配置，日志等",CLOUD_APP_VERSION,CLOUD_APP_URL),
        AUTH("auth","free-cloud-auth","free-cloud-auth账户权限",CLOUD_APP_VERSION,CLOUD_APP_URL),
        ;

        private String title;
        private String description;
        private String groupName;
        private String url;
        private String version;

        CloudApp(String groupName,String title,String description,String version,String url){
            this.groupName = groupName;
            this.title = title;
            this.description = description;
            this.version = version;
            this.url = url;
        }
    }

    /**
     *  服务名称（sytem）
     */
    public static final String CLOUD_APP_NAME_SYTEM = "system";
    /**
     *  服务名称（oss）
     */
    public static final String CLOUD_APP_NAME_OSS = "oss";

    /**
     *  服务名称（auth）
     */
    public static final String CLOUD_APP_NAME_AUTH = "auth";

    /**
     *  系统内部调用权限名
     */
    public static final String CLOUD_APP_PERMISSIONS_SYSTEM = "system:feign";


    /**
     * 所有内部调用权限名
     */
    public static final Set<String> CLOUD_APP_PERMISSIONS_ALL = new HashSet<>(Arrays.asList(
            CLOUD_APP_PERMISSIONS_SYSTEM
    ));


    /**
     * 远程调用类型
     */
    @Getter
    public enum RemoteCallType{
        LOCAL("local"),
        HTTP("http"),
        RPC("rpc");

        private String value;

        RemoteCallType(String value){
            this.value = value;
        }
    }
}
